<template>
  <div class="elm-edit">
    <elm-page-bb>
      <el-form ref="model" :model="model" size="small" label-width="80px">
        <elm-row>
          <el-form-item label="跟进客户" prop="gjkh" :rules="[{ required: true, message: '必须填写'}]">
            <elm-cus v-model="model.gjkh"></elm-cus>
          </el-form-item>
          <el-form-item label="跟进人" prop="gjr">
            <elm-ei v-model="model.gjr"></elm-ei>
          </el-form-item>
        </elm-row>
        <el-form-item label="跟进信息" prop="gjxx">
          <el-input v-model="model.gjxx"></el-input>
        </el-form-item>
        <elm-row>
          <el-form-item label="跟进时间" prop="gjsj">
            <el-date-picker v-model="model.gjsj" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" style="width: 100%">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="跟进方式" prop="gjfs">
            <elm-code dict_type="crm_follow_fs" v-model="model.gjfs"></elm-code>
          </el-form-item>
        </elm-row>
          <el-form-item label="沟通结果" prop="gjjg">
            <el-input v-model="model.gjjg"></el-input>
          </el-form-item>
        <el-form-item label="痛点需求" prop="khxq">
          <el-input  type="textarea" :rows="2" v-model="model.khxq"></el-input>
        </el-form-item>
        <elm-row>
          <el-form-item label="关联线索" prop="glxs">
            <elm-select-input :show-id="true" v-model="model.glxs" url="/business/my/GetLeadData"></elm-select-input>
          </el-form-item>
          <el-form-item label="关联商机" prop="glsj">
            <elm-select-input :show-id="true" v-model="model.glsj" url="/business/my/GetOppoData"></elm-select-input>
          </el-form-item>
        </elm-row>
        <el-form-item label="资料">
          <elm-upload module_name="biz_crm_follow_file" :rel_id="model.id" :multiple="true" :limit="10"  list-type="picture" tip=" "></elm-upload>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input type="textarea" :rows="2" v-model="model.remark"></el-input>
        </el-form-item>
      </el-form>
      <template #bottom>
        <el-button type="success" size="small" @click="submit">立即保存</el-button>
        <el-button size="small" @click="close">取消</el-button>
      </template>
    </elm-page-bb>
  </div>
</template>

<script>
export default {
  extends: elmVueBase,
  data() {
    return {
      model: {id: elm.newGuid()},
    }
  },
  async created() {
  },
  methods: {

    async submit() {
      await this.$refs["model"].validate();
      var res = await elm.post('/business/crm/follow/Upsert', this.model);
      if (res == true) {
        this.v('保存成功。')
        this.close();
        this.request.callVue.tablebinding();
      }
      else {
        this.error('保存失败，请稍后尝试。');
      }
    },
  }
}
</script>